<?php
/* 
 * Copyright (c) 2011 Antoine d'Otreppe de Bouvette
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 */

/**
 * Description of RenderMeResponse
 *
 * @author antoine
 */
class RenderMeResponse implements Response {
    /**
     * @var TemplateRenderer
     */
    private $templateRenderer;
    
    /**
     *
     * @var string
     */
    private $template;
    
    /**
     *
     * @var array
     */
    private $vars;
    
    /**
     *
     * @var int
     */
    private $code = 200;
    
    /**
     *
     * @var string
     */
    private $message = 'Ok';
    
    public function output() {
        header("HTTP/1.0 {$this->code} {$this->message}");
        echo $this->templateRenderer->renderTemplate(
                $this->template,
                $this->vars);
    }
    
    /**
     *
     * @return TemplateRenderer
     */
    public function getTemplateRenderer() {
        return $this->templateRenderer;
    }

    /**
     *
     * @param TemplateRenderer $templateRenderer 
     */
    public function setTemplateRenderer(TemplateRenderer $templateRenderer) {
        $this->templateRenderer = $templateRenderer;
    }

    /**
     *
     * @return string
     */
    public function getTemplate() {
        return $this->template;
    }

    /**
     *
     * @param string $template 
     */
    public function setTemplate($template) {
        $this->template = $template;
    }

    /**
     *
     * @return array
     */
    public function getVars() {
        return $this->vars;
    }

    /**
     *
     * @param array $vars 
     */
    public function setVars(array $vars) {
        $this->vars = $vars;
    }

    /**
     *
     * @return int
     */
    public function getCode() {
        return $this->code;
    }

    /**
     *
     * @param int $code 
     */
    public function setCode($code) {
        $this->code = $code;
    }

    /**
     *
     * @return string
     */
    public function getMessage() {
        return $this->message;
    }

    /**
     *
     * @param string $message 
     */
    public function setMessage($message) {
        $this->message = $message;
    }
}
